<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Cerberus | Homepage</title>

    <link href="css/style.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" href="css/font-awesome.min.css">
    <link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
    <!-- SlidesJS Required: Link to jQuery -->
    <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
    <script src="js/header.js"></script>

    <script>
        //if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
        //    alert('meo');
        //}
    </script>
    <!-- End SlidesJS Required -->
</head>
<body>
<div id="fb-root"></div>
<?php
if ($_REQUEST['message'] != null) {
    $message = $_REQUEST['message'];
    echo "<script>alert($message);</script>";
}
?>
<div class="toppanelholder">
    <div class="wrapper">
        <div id="toppanel">
            <div class="toppanel-wrapper">
                <?php
                require_once 'class/user.class.php';
                session_start();
                $user = unserialize($_SESSION['user']);
                session_write_close();
                if ($user == null)
                {
                    echo '<form id="login" action="login.php" method="POST" style="margin-top: 10px">';
                    echo '<div style="float: left; margin-right: 10px"><p style="margin: 0px 0px 0px 0px"><label for="username">Username</label></p>';
                    echo '    <input type="text" name="username" id="username" /></div>';
                    echo '    <div style="float: left; margin-right: 10px"><p style="margin: 0px 0px 0px 0px"><label for="psw">Password</label></p>';
                    echo '    <input type="password" name="psw" id="psw" class=""/></div>';
                    echo '    <div style="float: left;"><p style="margin: 0px 0px 0px 0px; color:rgba(0,0,0,0)">meo</p><input type="submit" class="btn btn-success" value="Login"/></div>';
                    echo '<div style="clear: both"></div>';
                    if ($_REQUEST['login'] == 'fail')
                              echo '<p style="color:#f77800" id="#error"> X Invalid user or password</p>';
                    echo '        <div style="margin-top: 10px"><a href="#">Forgot Password?</a>';
                    echo '        <a href="register.php">Register?</a>';
                    echo '        <a href="#" onclick="connectFB()"><img src="images/facebook_login.png" id="facebook_login"/></a></div>';
                    echo '</form>';
                }
                else
                {
                    echo '<p style="padding-top: 15px">';
                    $user_full_name = $user->userName;
                    $user_email = $user->emailAddress;
                    echo "Hello <a href='#' onclick='fullProfile()'> ".$user->loginName."</a>";
                    echo '        <a href="logout.php">Log out</a>&nbsp;&nbsp;&nbsp;';
                    echo '</p>';
                    echo "<p id='full'>Full name: $user_full_name | Email: $user_email</p>";
                }

                ?>
            </div>
        </div>
    </div>
</div>

<div class="wrapper">
    <header>
        <div id="logo">
            <img src="images/logo.gif" width="203" height="84" />
        </div>
    </header>
    <nav>
        <ul>
            <?php
            echo '<li><a href="index.php">home</a></li>';
            if ($user != null)
            {
                if ($user->userRole != 'admin')
                {
                echo '<li><a href="chat/">chat room</a></li>';
                echo '<li><a href="booking.php">booking</a></li>';
                }
                else
                    echo '<li><a href="users.php">Admin Panel</a></li>';
            }
            echo '<li><a href="contact.php">contact</a></li>';
            echo '<li><a href="about.php">about</a></li>';
            ?>
        </ul>
    </nav>
</div>
</body>
</html>